package Vista;
import javax.swing.JTable;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

import Controlador.Sistema;
import Negocio.Plan;


/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class ServiciosAgregados extends javax.swing.JFrame {
	private JTable tblServicios;
	private Sistema sistema;
	private Plan plan;

	/**
	* Auto-generated main method to display this JFrame
	*/
	
	public ServiciosAgregados(Sistema s, Plan p) {
		super();
		sistema = s;
		plan = p;
		initGUI();
		cargartabla();
		
	}
	
	private void cargartabla() {
		int i = 0;
		int j = 1;
		while(i< plan.getItems().size()){
			tblServicios.setValueAt(plan.getItems().get(i).getServicio().getNombre() , j, 0);
			tblServicios.setValueAt(String.valueOf( plan.getItems().get(i).getCostoAdicional()), j, 1);
			tblServicios.setValueAt(String.valueOf(plan.getItems().get(i).getUnidadesLibres()), j, 2);
			i++;
			j++;
		}
		
	}

	private void initGUI() {
		try {
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			getContentPane().setLayout(null);
			{
				TableModel tblServiciosModel = 
						new DefaultTableModel(
								new String[][] { { "Servicio", "Costo Adicional" ,"Unidades Libres", "" } ,{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""},{ "", "" ,"" , ""} },
								new String[] { "Column 1", "Column 2", "Column 3" });
				tblServicios = new JTable();
				getContentPane().add(tblServicios);
				tblServicios.setModel(tblServiciosModel);
				tblServicios.setBounds(5, 12, 457, 244);
			}
			pack();
			this.setSize(490, 300);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}

}
